package com.cx330;

public class Example22 {
    public static void main(String[] args) {
        int totalMoney = 100; // 总金额
        int totalChickens = 100; // 总鸡数
        for (int roosters = 1; roosters <= totalMoney / 5; roosters++) {
            for (int hens = 1; hens <= totalMoney / 3; hens++) {
                int chicks = totalChickens - roosters - hens;
                int cost = roosters * 5 + hens * 3 + chicks / 3;
                // 检查是否满足条件
                if (chicks >= 1 && chicks % 3 == 0 && cost == totalMoney) {
                    System.out.println("公鸡：" + roosters + "只，母鸡：" + hens + "只，小鸡：" + chicks + "只");
                }
            }
        }
    }
}
